package com.spzx.payment.controller;


import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.payment.service.AlipayService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("alipay")
public class AlipayController extends BaseController {

    @Autowired
    AlipayService alipayService;

   /* @Autowired
    AlipayService alipayService;*/

    @PostMapping("/callback")
    public String callback(HttpServletRequest request, @RequestParam Map<String, String> paramsMap){
        Map<String, String[]> parameterMap = request.getParameterMap();
        // 调用支付成功业务，通知系统，订单修改，扣减库存，生成物流等
        alipayService.callback(paramsMap);
        return "success";
    }

    @GetMapping("/submitAlipay/{orderNo}")
    public AjaxResult submitAlipay(@PathVariable String orderNo){
        String form = alipayService.submitAlipay(orderNo);  // 使用阿里的sdk, 生成支付表单
        return success(form);
    }

   /* @PostMapping("/callback")
    public String callback(HttpServletRequest request, @RequestParam Map<String,String> paramsMap){
        Map<String, String[]> parameterMap = request.getParameterMap();
        // 调用支付成功业务，通知系统，订单修改，扣减库存，生成物流等
        alipayService.callback(paramsMap);
        return "success";
    }*/



    /*@GetMapping("/submitAlipay/{orderNo}")
    public AjaxResult submitAlipay(@PathVariable String orderNo){
        String form = alipayService.submitAlipay(orderNo);// 使用阿里的sdk，生成支付表单
        return success(form);
    }*/
}
